package com.example.blog.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * @Question SendMailSevice
 * @Date 2023/1/23 0:37
 * @Solution
 */
@Service
public class SendMailSevice {
    @Autowired
    JavaMailSender javaMailSender;

    @Value("${spring.mail.username}")
    private String sendFrom;

    public void sendEmail(String accept,String content) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(sendFrom);
        message.setTo(accept);
        //标题
        message.setSubject("UR Blog忘记密码");
        //内容
        message.setText(content);
        javaMailSender.send(message);
    }
}
